/**
 * 主题变化
 */

   var activateDarkMode = function () {
     document.documentElement.setAttribute('data-theme', 'dark')
     if (document.querySelector('meta[name="theme-color"]') !== null) {
       document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
     }
   }
   var activateLightMode = function () {
     document.documentElement.setAttribute('data-theme', 'light')
     if (document.querySelector('meta[name="theme-color"]') !== null) {
       document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
     }
   }

   var autoChangeMode = 'false'
   var t = saveToLocal.get('theme')
   if (autoChangeMode === '1') {
     var isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
     var isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
     var isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
     var hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified

     if (t === undefined) {
       if (isLightMode) activateLightMode()
       else if (isDarkMode) activateDarkMode()
       else if (isNotSpecified || hasNoSupport) {
         var now = new Date()
         var hour = now.getHours()
         var isNight = hour <= 6 || hour >= 18
         isNight ? activateDarkMode() : activateLightMode()
       }
       window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
         if (saveToLocal.get('theme') === undefined) {
           e.matches ? activateDarkMode() : activateLightMode()
         }
       })
     } else if (t === 'light') activateLightMode()
     else activateDarkMode()
   } else if (autoChangeMode === '2') {
     now = new Date()
     hour = now.getHours()
     isNight = hour <= 6 || hour >= 18
     if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
     else if (t === 'light') activateLightMode()
     else activateDarkMode()
   } else {
     if (t === 'dark') activateDarkMode()
     else if (t === 'light') activateLightMode()
   }
